package person.twj.securitysessionredis.service.impl;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import person.twj.securitysessionredis.domain.po.SysUser;
import person.twj.securitysessionredis.service.ISysUserService;

import java.util.Random;

@Service
public class SysUserServiceImpl implements ISysUserService {

    @Override
    public SysUser selectByUserName(String username) {
        Random random = new Random();
        long randomLong = random.nextLong();

        if("admin".equals(username)){
            return SysUser.builder()
                    .userId(randomLong)
                    .username("admin")
                    .password(new BCryptPasswordEncoder().encode("admin2"))
                    .build();
        }
        return null;
    }
}
